package com.liyuci.core.helper;

/**
 * 字符串工具类
 * @author liyuci
 * @date 2018-02-04 17:55:32
 */
public class StringsHelp
{

	/**
	 * 将首字母变成大写
	 * @author liyuci
	 * @date 2018-02-04 17:56:01
	 * @param str
	 * @return
	 */
	public static String toUpperFristChar(String str)
	{
		if(BlankHelper.isNotBlank(str))
		{
			char[] charArray = str.toCharArray();
			charArray[0] -= 32;
			return String.valueOf(charArray);
		}
		return str;
	}

	/**
	 * 将首字母变成小写
	 * @author liyuci
	 * @date 2018-02-04 17:57:50
	 * @param str
	 * @return
	 */
	public static String toLowerFristChar(String str)
	{
		if(BlankHelper.isNotBlank(str))
		{
			char[] charArray = str.toCharArray();
			charArray[0] += 32;
			return String.valueOf(charArray);
		}
		return str;
	}

	/**
	 * 字符串从后面开始删除几个字符
	 * @author liyuci
	 * @date 2018-02-04 18:02:27
	 * @param str
	 * @param count
	 * @return
	 */
	public static String removeStringFromLast(String str, int count)
	{
		if(BlankHelper.isNotBlank(str) && str.length() > count)
		{
			return str.substring(0, str.length() - count);
		}
		if(BlankHelper.isNotBlank(str) && str.length() <= count)
		{
			return "";
		}
		return str;
	}

}
